package file;

@Deprecated
public class BitMask {
	static final int maskAllOff = 0;						// 00000000000000000000000000000000
	static final int maskBit0 = 1; 							// 00000000000000000000000000000001
	static final int maskBit1 = 2; 							// 00000000000000000000000000000010
	static final int maskBit2 = 4; 							// 00000000000000000000000000000100
	static final int maskBit3 = 8; 							// 00000000000000000000000000001000
	static final int maskBit4 = 16;							// 00000000000000000000000000010000
	static final int maskBit5 = 32;							// 00000000000000000000000000100000
	static final int maskBit6 = 64;							// 00000000000000000000000001000000
	static final int maskBit7 = 128;						// 00000000000000000000000010000000
	static final int maskBit8 = 256;						// 00000000000000000000000100000000
	static final int maskBit9 = 512;						// 00000000000000000000001000000000
	static final int maskBit10 = 1024;						// 00000000000000000000010000000000
	static final int maskBit11 = 2048;						// 00000000000000000000100000000000
	static final int maskBit12 = 4096;						// 00000000000000000001000000000000
	static final int maskBit13 = 8192;						// 00000000000000000010000000000000
	static final int maskBit14 = (int) Math.pow(2, 14);		// 00000000000000000100000000000000
	static final int maskBit15 = (int) Math.pow(2, 15);		// 00000000000000001000000000000000
	static final int maskBit16 = (int) Math.pow(2, 16);		// 00000000000000010000000000000000
	static final int maskBit17 = (int) Math.pow(2, 17);		// 00000000000000100000000000000000
	static final int maskBit18 = (int) Math.pow(2, 18);		// 00000000000001000000000000000000
	static final int maskBit19 = (int) Math.pow(2, 19);		// 00000000000010000000000000000000
	static final int maskBit20 = (int) Math.pow(2, 20);		// 00000000000100000000000000000000
	static final int maskBit21 = (int) Math.pow(2, 21);		// 00000000001000000000000000000000
	static final int maskBit22 = (int) Math.pow(2, 22);		// 00000000010000000000000000000000
	static final int maskBit23 = (int) Math.pow(2, 23);		// 00000000100000000000000000000000
	static final int maskBit24 = (int) Math.pow(2, 24);		// 00000001000000000000000000000000
	static final int maskBit25 = (int) Math.pow(2, 25);		// 00000010000000000000000000000000
	static final int maskBit26 = (int) Math.pow(2, 26);		// 00000100000000000000000000000000
	static final int maskBit27 = (int) Math.pow(2, 27);		// 00001000000000000000000000000000
	static final int maskBit28 = (int) Math.pow(2, 28);		// 00010000000000000000000000000000
	static final int maskBit29 = (int) Math.pow(2, 29);		// 00100000000000000000000000000000
	static final int maskBit30 = (int) Math.pow(2, 30);		// 01000000000000000000000000000000
	static final int maskBit31 = (int) Math.pow(2, 31);		// 10000000000000000000000000000000
	static final int maskBitAllOn = -1;						// 11111111111111111111111111111111
	
	private int mask;
	private int length;
	
	public BitMask(){
		this.mask = maskAllOff;
		this.length = 32;
	}
	
	public BitMask(int m){
		this.mask = m;
		this.length = 32;
	}
		
	public BitMask(int m, int length){
		this.mask = m;
		this.length = length;
	}
	
	
	public int getValue(){
		return this.mask;
	}
	
	
	public void setValue(int mask) {
		this.mask = mask;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

	//Indice goes from 0 to 31
	public void setBitToOne(int bitIndice){
		if(bitIndice < 31 && this.mask != 0x7FFFFFFF)
			this.mask |= (int) Math.pow(2, bitIndice);
		else
			this.mask = maskBitAllOn;
	}
	
	//Indice goes from 0 to 31
		public void setBitToZero(int bitIndice){
			int bitToZero = (int) (maskBitAllOn - Math.pow(2, bitIndice));
			this.mask &= bitToZero;
		}
	
}
